﻿using System;
using System.Collections.ObjectModel;
using System.IO;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            /*
            var dir = @"D:\gits\gitlab\AdventureWorksIdentity";
            var file = @"D:\gits\gitlab\AdventureWorksIdentity\.git\objects\00\c2b429da04543a129cd2fa3dbd6af876182f56";
            Console.WriteLine(File.Exists(file));
            Console.WriteLine(Path.GetExtension(file));
            var fileInfo = new FileInfo(file);
            Console.WriteLine(fileInfo.Attributes.HasFlag(FileAttributes.Hidden));
            Console.WriteLine(Path.GetFileName(dir));
            Console.WriteLine("Hello World!");

             */

            var now = DateTime.UtcNow;
            Console.WriteLine(now.Kind.ToString());


            DateTime thisDate = new DateTime(2007, 3, 10, 0, 0, 0);
            DateTime dstDate = new DateTime(2007, 6, 10, 0, 0, 0);
            DateTimeOffset thisTime;

            thisTime = new DateTimeOffset(dstDate, new TimeSpan(-7, 0, 0));
            ShowPossibleTimeZones(thisTime);

            thisTime = new DateTimeOffset(thisDate, new TimeSpan(-6, 0, 0));
            ShowPossibleTimeZones(thisTime);

            thisTime = new DateTimeOffset(thisDate, new TimeSpan(+1, 0, 0));
            ShowPossibleTimeZones(thisTime);

            var datetimeOffset = DateTimeOffset.UtcNow.Add(TimeSpan.FromMinutes(5));
            Console.WriteLine(datetimeOffset.LocalDateTime);
            ShowPossibleTimeZones(datetimeOffset);
            //Console.WriteLine(datetimeOffset.DateTime);
        }

        private static void ShowPossibleTimeZones(DateTimeOffset offsetTime)
        {
            TimeSpan offset = offsetTime.Offset;
            ReadOnlyCollection<TimeZoneInfo> timeZones;

            Console.WriteLine("{0} could belong to the following time zones:", offsetTime.ToString());
            // Get all time zones defined on local system
            timeZones = TimeZoneInfo.GetSystemTimeZones();
            // Iterate time zones 
            foreach (TimeZoneInfo timeZone in timeZones)
            {
                // Compare offset with offset for that date in that time zone
                if (timeZone.GetUtcOffset(offsetTime.DateTime).Equals(offset))
                    Console.WriteLine("   {0}", timeZone.DisplayName);
            }
            Console.WriteLine();
        }
    }

}
